package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 保存套餐和菜品的关联关系
 */
@Mapper
public interface SetmealDishMapper {

    List<Long> getSetmealIdsByDishId(List<Long> ids);

    /*更新套餐*/
    @AutoFill(value= OperationType.UPDATE)
    void update(Setmeal setmeal);

    /*插入套餐和菜品之间的关联信息*/
    void insertBatch(List<SetmealDish> setmealDishes);

    /*根据套餐id删除setmeal_dish表中对应的菜品*/
    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealId(Long setmealId);

    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getBySetmealId(Long id);
}
